package com.neusoft.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.neusoft.dao.AdminDao;
import com.neusoft.entity.Admin;
import com.neusoft.entity.AdminQuery;
import com.neusoft.entity.BanJi;
import com.neusoft.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;


import javax.annotation.Resource;
import java.util.List;

/**
 * (Admin)表服务实现类
 *
 * @author makejava
 * @since 2020-05-26 09:13:47
 */
@Service("adminService")
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminDao adminDao;

   @Override
    public Admin login(String account, String password) {
        return adminDao.login(account,password);
    }

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Admin queryById(Integer id) {
        return this.adminDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public IPage<Admin> queryAllByLimit(int offset, int limit, AdminQuery bean) {
        Page<Admin> page = new Page<>(offset,limit);
        page.setRecords(adminDao.queryAll(page,bean));
    /*    System.out.println("总页数：" + page1.getPages());
        System.out.println("总页数：" + page1.getTotal());*/
        return page;
    }

    @Override
    public List<Admin> queryAll(AdminQuery bean) {
        return null;
    }
//    @Override
//    public List<Admin> queryAll(AdminQuery bean) {
//        return null;
//    }
/*
    *//**
     * 新增数据
     *
     * @param admin 实例对象
     * @return 实例对象
     *//*
    @Override
    public Admin insert(Admin admin) {
        this.adminDao.insert(admin);
        return admin;
    }

    *//**
     * 修改数据
     *
     * @param admin 实例对象
     * @return 实例对象
     *//*
    @Override
    public boolean update(Admin admin) {

        return adminDao.update(admin)>0;
    }

    *//**
     * 通过主键删除数据
     *
     * @param ids 主键
     * @return 是否成功
     *//*
    @Override
    public boolean deleteById(List<Integer> ids) {
        if(ids == null || ids.size() == 0) {
            return false;
        }
        StringBuffer sb = new StringBuffer("id in (");
        for (Integer item : ids) {
            sb.append("'");
            sb.append(item);
            sb.append("',");
        }
        sb.deleteCharAt(sb.lastIndexOf(","));
        sb.append(")");

        return adminDao.delete("stu.admin", sb.toString()) > 0;
    }*/
}